<include file="Public:header" />
<div class="container clearfix">
    <include file="Public:sidebar" />
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.html">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">充值查询</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="<!--{:U('paylog/index')}-->" method="post">
                    <table class="search-tab">
                        <tr>
                            <td>订单号</td>
                            <td><input class="common-text" type="text" name="order_num" id="order_num" value="<!--{$order_num}-->"/></td>
                            <td>充值账号</td>
                            <td><input class="common-text" placeholder="充值账号" name="username" value="<!--{$username}-->"  size="10" id="username" type="text"></td>
                            <td>支付渠道</td>
                            <td>
                                <select name='payid' id='paytype'>
                                    <option>所有渠道</option>
                                </select>
                            </td>
                            <td>
                                <select name="game_id" id='game'>
                                    <option>选择游戏</option>
                                </select>
                            </td>
                            <td>
                                <select name="area_num" id='server'>
                                    <option>选择区服</option>
                                </select>
                            </td>
                            <td>时间</td>
                            <td><input class="common-text" name="data_start" type="text" onClick="WdatePicker()" value="<!--{$dt1}-->" size="10"></td><td><input class="common-text" name="data_end" type="text" onClick="WdatePicker()" value="<!--{$dt2}-->" size="10"></td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>订单号</th>
                            <th>用户名</th>
                            <th>充值账号</th>
                            <th>渠道来源</th>
                            <th>支付渠道</th>
                            <th>充值金额</th>
                            <th>充值时间</th>
                            <th>订单描述</th>
                            <th>支付状态</th>
                            <th>到游戏账户</th>
                            <th>操作</th>
                        </tr>
                        <?php foreach($list as $v){?>
                        <tr>                            
                            <td><?php echo $v['order_num']?></td>
                            <td><?php echo $v['username']?></td>
                            <td><?php echo $v['pay_username']?></td>
                            <td><?php echo $v['refername']?></td>
                            <td><?php echo $v['paytypename']?></td>
                            <td><?php echo $v['pay_cny']?></td>
                            <td><?php echo date("Y-m-d H:i:s",$v['pay_time']);?></td>
                            <td><?php echo $v['discript']?></td>
                            <td><?php if($v['flag']==1){echo "<font color='green'>已到账</font>";}else{echo "未到账";}?></td>
                            <td><?php if($v['flag_game']==1){echo "<font color='green'>已到游戏</font>";}else{echo "<font color='red'>未到游戏</font>";}?></td>
                            <td>
                                <?php if($v['flag']==1 && $v['flag_game']==0){?>
                                <a class="link-update" href="#"><?php echo "补单";?></a>          
                                <?php } ?>
                            </td>
                        </tr>
                        <?php }?>
                    </table>
                    <div class="list-page"><!--{$page}--></div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
<script type="text/javascript">
    var game=<!--{$gamelist}--> ;
    var paytype=<!--{$paytype}-->;
    var game_id = <!--{$game_id}--> ? <!--{$game_id}--> : 0;
    var area_num = <!--{$area_num}--> ? <!--{$area_num}--> : 0;
    var payid = <!--{$payid}--> ? <!--{$payid}--> : 0;
    $(function () {
        init_game();
        init_paytype();
        $("#game").change(function () {
            game_id=$(this).val();
            $.ajax({
                type:'get',
                url:'http://www.248game.com/admin.php?s=/paylog/serverlist',
                data:{'game_id':game_id},
                dataType:'json',
                success:function(data){
                    var html='<option value="">--全部区服--</option>';
                    for(i=0;i<data.length;i++){
                        html+='<option value="'+data[i]['area_num']+'">'+data[i]['areaname']+'</option>';
                    }
                    $("#server").html(html)
                }
            });
        });
        $("#server").change(function(){
            area_num=$(this).val();
        });        
        if(game_id!=0 && area_num!=0){
            init_server(game_id,area_num);
        }
    });
    function init_game() {
        var html = '<option value="">--全部游戏--</option>'
        for (i = 0; i < game.length; i++) {
            if(game_id!=0 && game_id==game[i]['id']){
                html += '<option value="' + game[i]['id'] + '" selected="selected">' + game[i]['gamename'] + '</option>'
            }
            html += '<option value="' + game[i]['id'] + '">' + game[i]['gamename'] + '</option>'
        }        
        $("#game").html(html);
    }
    function init_server(game_id,area_num){
        $.ajax({
                type:'get',
                url:'http://www.248game.com/admin.php?s=/paylog/serverlist',
                data:{'game_id':game_id},
                dataType:'json',
                success:function(data){
                    var html='<option value="">--全部游戏--</option>';
                    for(i=0;i<data.length;i++){
                        if(area_num!=0 && area_num==data[i]['area_num']){
                            html+='<option value="'+data[i]['area_num']+'" selected="selected">'+data[i]['areaname']+'</option>';
                        }
                        html+='<option value="'+data[i]['area_num']+'">'+data[i]['areaname']+'</option>';
                    }
                    $("#server").html(html)
                }
            });
    }
    function init_paytype(){
        var html='<option value="">所有渠道</option>';
        for(i=0;i<paytype.length;i++){
            if(payid!=0 && payid==paytype[i]['id']){
                html+='<option value="'+paytype[i]['id']+'" selected="selected">'+paytype[i]['typename']+'</option>';
            }
            html+='<option value="'+paytype[i]['id']+'">'+paytype[i]['typename']+'</option>';
        }
        
        $("#paytype").html(html);
    }
</script>
</body>
</html>